package com.example.usedemo.controller;

import com.example.usedemo.dao.RoleMapper;
import com.example.usedemo.dao.UserRoleMapper;
import com.example.usedemo.domain.UserRole;
import com.example.usedemo.results.UserRoleResult;
import lombok.extern.flogger.Flogger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("/userRole")
public class UserRoleController {
    static Logger logger = LoggerFactory.getLogger(UserRoleController.class);

    @Autowired
    UserRoleMapper userRoleMapper;


    //wsb应该是一个前端传来的信息，或者由信息进行处理的数据
    @GetMapping("/getRoleByUserId/{id}")
    public HashMap<String ,Object> getRole(@PathVariable("id") String id){
//      List<String> userRole=userRoleMapper.findRoleidByUserid(id);
        List<UserRoleResult> results=userRoleMapper.findRoleinfoByUserid(id);
        logger.info("results:{}",results);
        HashMap<String,Object> map=new HashMap<>();
        map.put("roles",results);
        return map;
    }
}
